package com.huangkailong.designpattern.prototype;

import java.util.ArrayList;

/**
 * 原型模式测试.
 *
 * @author huangkl
 * @since 1.0.0
 */
public class Client {
    /**
     * main 方法.
     */
    public static void main(String[] args) {
        ShallowClonePrototype shallowClonePrototype = new ShallowClonePrototype();
        ArrayList<String> hobbies = new ArrayList<>();
        hobbies.add("跑步");
        hobbies.add("唱歌");
        shallowClonePrototype.setHobbies(hobbies);
        shallowClonePrototype.setUserName("test");
        shallowClonePrototype.setPassword("test");
        ShallowClonePrototype shallowClonePrototype1 = shallowClonePrototype.clone();
        System.out.println(shallowClonePrototype.equals(shallowClonePrototype1));
        hobbies.add("跳舞");
        System.out.println(shallowClonePrototype.equals(shallowClonePrototype1));

        DeepClonePrototype deepClonePrototype = new DeepClonePrototype();
        ArrayList<String> hobbies1 = new ArrayList<>();
        hobbies1.add("跑步");
        hobbies1.add("唱歌");
        deepClonePrototype.setHobbies(hobbies1);
        deepClonePrototype.setUserName("test");
        deepClonePrototype.setPassword("test");
        DeepClonePrototype deepClonePrototype1 = deepClonePrototype.clone();
        System.out.println(deepClonePrototype.equals(deepClonePrototype1));
        hobbies1.add("跳舞");
        System.out.println(deepClonePrototype.equals(deepClonePrototype1));
    }
}
